const express = require('express')
const app = express()
const {port}  = require('./utils/config.js')

// 为user表添加初始数据
// const user = require('./model/user.js')

// 
const router = require('./router/index')
const {createConnect} = require('./mongoose.js')

// 配置跨域
const cors = require('cors')
app.use(cors())


// 配置静态文件
// app.use('/public',express.static('./public'))

//参数json
app.use(express.json())
app.use(express.urlencoded({ extended:false}))

// 连接数据库
createConnect()

// 配置路由
app.use('/api',router)








app.listen(port,()=>{
  console.log(`服务器启动成功${port}`);
})